import 'package:flame/components.dart';
import 'package:flutter_flame/routes/RouteGame.dart';
import '../../component/MaskedImageComponent.dart';
import '../../component/ScaleSpriteComponent.dart';
import 'audio/SoundManager.dart';
import 'components/SelectorScreenButtonsComponent.dart';
import 'components/SelectorScreenCloudComponent.dart';
import 'components/SelectorScreenFlowersComponent.dart';
import 'components/SelectorScreenLeavesComponent.dart';
import 'components/SelectorScreenNotesComponent.dart';
import '../../config/AssetsName.dart';
import 'components/SelectorScreenWoodSignComponent.dart';

class WelcomeMenuWorld extends World with HasGameReference<RouterGame> {
  static String routeName = "menu";

  @override
  Future<void> onLoad() async {
    SoundManager().init(); // 背景音乐
    final selectorScreenBgCenter = MaskedImageComponent(
      maskImagePath: AssetsName.spriteSelectorScreenBgCenter_,
      colorImagePath: AssetsName.spriteSelectorScreenBgCenter,
      pixelOffset: -1,
      setWidth: 700,
      position: Vector2(-400, 10),
    );
    final selectorScreenBgLeft = MaskedImageComponent(
      maskImagePath: AssetsName.spriteSelectorScreenBgLeft_,
      colorImagePath: AssetsName.spriteSelectorScreenBgLeft,
      setWidth: 520,
      position: Vector2(-480, -360),
    );
    final selectorScreenBgRight = MaskedImageComponent(
      maskImagePath: AssetsName.spriteSelectorScreenBgRight_,
      colorImagePath: AssetsName.spriteSelectorScreenBgRight,
      setWidth: 830,
      position: Vector2(-350, -270),
      pixelOffset: -0.4
    );
    addAll([
      _SelectorScreenBg(), // 背景天空
      SelectorScreenCloudComponent(), // 云
      selectorScreenBgCenter, // 房子
      selectorScreenBgLeft, // 大树,
      SelectorScreenWoodSignComponent(), // 存档
      selectorScreenBgRight, // 墓碑
      SelectorScreenLeavesComponent(), // 左下的草
      SelectorScreenStartAdventureComponent(), // 开始按钮
      SelectorScreenSurvivalComponent(), // 玩玩小游戏
      SelectorScreenVaseBreakerComponent(), // 解谜模式
      SelectorScreenChallengesComponent(), // 生存模式
      SelectorScreenFlowersComponent(), // 右下角花朵
      SelectorScreenNotesComponent(), // 右下角的文字
    ]);
  }
}

class _SelectorScreenBg extends ScaleSpriteComponent {
  /// 背景天空
  _SelectorScreenBg()
      : super(
          1000,
          Vector2(-500, -400),
          AssetsName.spriteSelectorScreenBg,
        );
}
